<?php

/**
 * Description of XQL_DataSurce_RecordManager
 *
 * @author prometheus
 */
class XQL_DataSource_RecordManager extends x10_Manager
{
    protected $xqlStatement;

	public function __construct(x10_Config $config=NULL)
	{
		parent::__construct($config);
		$this->registerProvider(new x10_Provider_Descriptor('XQL_DataSource_RecordProvider'));
	}

	public function import($records)
	{
		$this->xqlStatement = NULL;
		foreach ($records as $record)
		{
			$record->recordManager = $this;
			if (is_null($this->xqlStatement)) $this->xqlStatement = $record->xqlStatement;
			$this[] = $record;
		}
	}

	public function exportRaw()
	{
		$result = array();
		foreach ((array)$this as $record)
		{
			$result[] = (array)$record->export();
		}
		return $result;
	}

	public function getOne()
	{
		return $this[0];
	}

	public function getColumn($fieldName)
	{
		$result = array();
		foreach ((array)$this as $record)
		{
			$result[] = $record->$fieldName;
		}
		return $result;
	}
}
?>
